{% extends 'base.html' %}

{% block title %}广告主控制面板{% endblock %}

{% block content %}
<!DOCTYPE html>
<html>
<head>
    <title>广告编辑控制面板</title>
    <style>
        body {
            font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
            background-color: #f8f9fb;
            margin: 0;
            padding: 40px 20px;
            color: #2d3436;
        }

        .dashboard-container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            padding: 40px;
            border-radius: 16px;
            box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
        }

        h2 {
            font-size: 32px;
            margin-bottom: 40px;
            padding-bottom: 20px;
            border-bottom: 3px solid #4a90e2;
        }

        h3 {
            color: #4a90e2;
            font-size: 24px;
            margin: 40px 0 25px;
        }

        /* 合同列表样式 */
        .contract-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .contract-item {
            background: #f8faff;
            padding: 20px;
            margin-bottom: 15px;
            border-radius: 10px;
            border: 1px solid #e3e9ff;
            transition: transform 0.2s;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .contract-item:hover {
            transform: translateX(10px);
            border-color: #4a90e2;
        }

        .edit-btn {
            background: #4a90e2;
            color: white;
            padding: 8px 20px;
            border-radius: 6px;
            text-decoration: none;
            transition: all 0.2s;
        }

        .edit-btn:hover {
            background: #357abd;
            box-shadow: 0 3px 8px rgba(74, 144, 226, 0.3);
        }

        /* 表格样式 */
        .content-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            overflow-x: auto;
        }

        .content-table th,
        .content-table td {
            padding: 16px;
            text-align: left;
            border-bottom: 1px solid #e9ecef;
        }

        .content-table th {
            background: #f8f9fb;
            font-weight: 600;
            color: #495057;
        }

        .content-table tr:hover {
            background-color: #f8f9fb;
        }

        /* 状态标签 */
        .status-pending { color: #f39c12; }
        .status-approved { color: #27ae60; }
        .status-rejected { color: #e74c3c; }

        @media (max-width: 768px) {
            .dashboard-container {
                padding: 25px;
                margin: 20px;
            }
            
            h2 {
                font-size: 28px;
            }
            
            .contract-item {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }
        }
    </style>
</head>
<body>
    <div class="dashboard-container">
        <h2>📝 广告编辑控制面板</h2>

        <h3>🆕 可编辑软广合同</h3>
        {% if editable_contracts %}
        <ul class="contract-list">
            {% for c in editable_contracts %}
                <li class="contract-item">
                    <div>
                        <strong>合同 #{{ c.id }}</strong> - 平台：{{ c.media }}
                    </div>
                    <a href="{% url 'edit_soft_contract' c.id %}" class="edit-btn">
                        ✏️ 开始编辑
                    </a>
                </li>
            {% endfor %}
        </ul>
        {% else %}
        <div class="empty-state">
            🎉 当前没有未编辑的软广合同
        </div>
        {% endif %}

        <h3>📚 我的编辑记录</h3>
        {% if my_contents %}
        <table class="content-table">
            <thead>
                <tr>
                    <th>合同ID</th>
                    <th>文案内容</th>
                    <th>图片</th>
                    <th>视频</th>
                    <th>状态</th>
                </tr>
            </thead>
            <tbody>
                {% for item in my_contents %}
                <tr>
                    <td>{{ item.contract.id }}</td>
                    <td>{{ item.content|truncatechars:50 }}</td>
                    <td>{{ item.image_path }}</td>
                    <td>{{ item.video_path }}</td>
                    <td class="status-{{ item.status }}">
                        {% if item.status == 'pending' %} ⏳ 待审核
                        {% elif item.status == 'approved' %} ✅ 已通过
                        {% elif item.status == 'rejected' %} ❌ 已驳回
                        {% else %} 未知
                        {% endif %}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        {% else %}
        <div class="empty-state">
            📭 你还没有编辑过软广内容
        </div>
        {% endif %}
    </div>
</body>
</html>
{% endblock %}